﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Logs;
using Test.Testitextsharp;
using Font = System.Drawing.Font;
using Spire.Pdf;

namespace Test.Print {
    public partial class PrintForm:Form {
        public PrintForm() {
            InitializeComponent();
        }

        /// <summary>
        /// 直接打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender,EventArgs e) {
            Common.Print print = new Common.Print("FeeList.pdf");
            if (print.PrintDirectly())
            {
                Log.Info("打印成功！");
            }
        }

        /// <summary>
        /// 打印每一页都会引发PrintPage事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void printDocument1_PrintPage(object sender,PrintPageEventArgs e) {

            //Graphics g = e.Graphics;    //获取绘图表面
            //string fileName = Path.Combine(Application.StartupPath,@"FeeList.pdf"); //TODO:无法打印PDF

            //Bitmap image = new Bitmap(fileName);
            //g.DrawImage(image,50,100);
        }

        private PrintDocument printpdf(string path) {
            Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
            doc.LoadFromFile(path);
            PrintDocument printDoc = doc.PrintDocument;
            return printDoc;
        }
    }
}
